const express = require('express');
const router = express.Router();
const Blog = require('../../mongoModuels/rear/blog');
const jwt = require('jsonwebtoken');


router
.get('/admin/nav', (req, res) => {
    Blog.left_nav.find({}, (err, data) => {
        if(err) {
            res.json({
                status: 0,
                message: '操作失败'
            })
        } else {
            let token = req.get("Authorization");
            let username = jwt.decode(token).username;
            if(username === 'admin') {
                res.json({
                    status: 1,
                    message: '操作成功',
                    data
                })
            } else {
                data.splice(0, 1);
                res.json({
                    status: 1,
                    message: '操作成功',
                    data
                })
            }
        }
    })
})

module.exports = router;